﻿Imports OPC.Common
Imports OPC.Data.Interface
Imports OPC.Data

Module modGlobalDefine

    '照片信息的结构体
    Public Structure struPicInfo
        Public picname As String
        Public picurl As String
        Public datastr As String
        Public crttime As DateTime
        Public linecode As String
        Public stackno As Integer
        Public stacknum As Integer
        Public picvalue As String
        Public directory As String
    End Structure

    '生产线信息的结构体
    Public Structure struLineInfo
        Public lineid As String
        Public job As String
        Public kickparam As Integer
        Public stackno As Integer
        Public stacknum As Integer
        Public cameraparam1 As Double
        Public cameraparam2 As Double
        Public cameraparam3 As Double
        Public cameraparam4 As Double
        Public cameraparam5 As Double
        Public cameraparam6 As Double
        Public ip As String
        Public stackTopNum As Integer
    End Structure

    '将主界面声明为全局form
    Public g_frmmain As frmMain

    'PLC数据格式
    Public Structure struPLCData
        Public lineid As String
        Public stackno As Integer
        Public stacknum As Integer
        Public producesum As Integer
        Public badpartnum As Integer
    End Structure

    Public stlineinfo As New struLineInfo

    Public struplcdate As New struPLCData 'PLC数据变量
    Public struformdate As New struPLCData '界面数据变量


    Public plcselectflag As Boolean = False
    Public picUrlRoot As String = "d:\InsightSavePic" '图片保存主目录
    Public spacemark As String = "_" '图片文件分割符
    Public pictype = ".jpg" '图片格式

    'Public port As New SerialPortCommDll.SerialPortObject '声明全局串口变量
    '定义串口通信结构变量
    'Public g_sp_comm_param As New SerialPortCommDll.Stru_Sp_Param

    '定义生产线字符串组
    Public plclinedate1 As String = ""
    Public plclinedate2 As String = ""
    Public plclinedate3 As String = ""
    Public plclinedate4 As String = ""
    Public plclinedatetemp As String = ""

    Public linedata(4) As struPLCData '4条生产线数据标量
    Public templinedata As struPLCData '临时的生产线数据变量，主要是为了对比前后数据

    Public plcorderflag As Boolean = False
    Public orderlist As New Hashtable

    Public TheSrv As OpcServer                           '声明OPC服务器
    Public WithEvents TheGrp As OpcGroup                 '声明OPC数据组

    Public plcaddr(plcparamnum) As String
    Public rItm(plcparamnum) As OPCItemResult                     'OPC结果集

    'Public lineonenum() As Integer = {0, 1, 2, 3}        '生产线1的数据在结果集中位置
    'Public linetwonum() As Integer = {6, 7, 8, 9}        '生产线2的数据在结果集中位置
    'Public linethreenum() As Integer = {12, 13, 14, 15}  '生产线3的数据在结果集中位置
    'Public linefournum() As Integer = {18, 19, 20, 21}   '生产线4的数据在结果集中位置

    Public linenum(,) = {{0, 1, 2, 3}, {6, 7, 8, 9}, {12, 13, 14, 15}, {18, 19, 20, 21}}  '生产线数据在结果集中位置
    Public prodsum() As Integer = {0, 6, 12, 18}         '产品总数在结果集中的位置
    Public badArraynum() As Integer = {1, 7, 13, 19}     '次品总数在结果集中的位置   
    Public duoshunum() As Integer = {2, 8, 14, 20}       '垛数的数据在结果集中位置
    Public dbsnum() As Integer = {3, 9, 15, 21}          '垛包数的数据在结果集中位置
    Public kicknum() As Integer = {5, 11, 17, 23}        '剔除脉冲的数据在结果集中位置
    Public drsnum() As Integer = {4, 10, 16, 22}         '垛所容量书在结果集中的位置   
    Public prodsumbak() As Integer = {24, 27, 30, 33}    '产品总数备份信息在结果集中的位置
    Public badprodsumbak() As Integer = {25, 28, 31, 34} '次品总数备份信息在结果集的位置
    Public prodsumtemp() As Integer = {26, 29, 32, 35}   '产品总数临时数据在结果集的位置   

    Public sp_Thread As Threading.Thread

    Public badprodnum As Integer = 0

    Public cid As Cognex.InSight.Controls.Display.CvsInSightDisplay

    '测试时间
    Public time1 As Date
    Public time2 As Date
    Public time3 As Date
    Public time4 As Date

    Public stackTopStr(3) As String

    Public classcode As String  '班次信息
    Public classname As String
    Public username As String   '登录员工

    Public MsgBoxTitle As String = "马鞍山包装检测系统"

    Public plcparamnum As Integer

    Public stacktopsum(4) As Integer
End Module
